simon-5502-05-slides

2025-02-18

Topics to be covered

  • What you will learn
    • Mathematical model of interactions
    • Interactions in multi-factor analysis of variance
    • Other examples of interactions
    • Interactions in analysis of covariance
    • Interactions in multiple linear regression

Mathematical model, 1

  • \(Y_{ijk}=\mu+\alpha_i+\beta_j+(\alpha \beta)_{ij}+\epsilon_{ijk}\)
    • i=1,…,a j=1,…,b, k=1,…,n
  • If 1 is the reference category
    • \(\alpha_1=0\)
    • \(\beta_1=0\)
    • \((\alpha \beta)_{1j}=0\)
    • \((\alpha \beta)_{i1}=0\)

Interpretation

  • \(\mu\), estimated average outcome for both A, B at reference level
  • \(\alpha\) average change from reference level for A holding B fixed at reference level
  • \(\beta\) average change from reference level for B holding A fixed at reference level
  • \(\alpha \beta\) average deviation from parallelism

Mathematical model, 2

  • \(SS_A=\Sigma_i nb(\bar{Y}_{i..}-\bar{Y}_{...})^2\)
  • \(SS_B=\Sigma_j na(\bar{Y}_{.j.}-\bar{Y}_{...})^2\)
  • \(SS_{AB}=\Sigma_i \Sigma_j n(\bar{Y}_{ij.}-\bar{Y}_{i..}-\bar{Y}_{.j.}+ \bar{Y}_{...})^2\)
  • \(SS_E=\Sigma_i \Sigma_j \Sigma_k (Y_{ijk}-\bar{Y}_{ij.})^2\)
  • \(SS_T=\Sigma_i \Sigma_j \Sigma_k (Y_{ijk}-\bar{Y}_{...})^2\)

Test for an interaction

  • \(SS_{AB}\) has (a-1)(b-1) degrees of freedom
  • \(SS_E\) has ab(n-1) degrees of freedom
  • Accept \(H_0\) if \(F=\frac{MS_{AB}}{MS_E}\) is close to one
    • In R, fit a model without an interaction
    • Compare to a model with interaction
    • Using the anova function

Break #1

  • What you have learned
    • Mathematical model of interactions
  • What’s coming next
    • Interactions in multi-factor analysis of variance

Hypothetical applications

  • Study with two drugs and two placebos
  • Four treatment options
    • Placebo plus placebo
    • Drug A plus placebo
    • Placebo plus Drug B
    • Drug A plus Drug B

Listing of hypothetical data

# A tibble: 8 × 3
  a     b         y
  <fct> <fct> <dbl>
1 P     P       0.9
2 P     P       1.1
3 A     P       2.9
4 A     P       3.1
5 P     B       3.9
6 P     B       4.1
7 A     B       9.9
8 A     B      10.1

Line plot of hypothetical data, 1

Create indicator variables

# A tibble: 8 × 6
  a     b       i_a   i_b  i_ab     y
  <fct> <fct> <dbl> <dbl> <dbl> <dbl>
1 P     P         0     0     0   0.9
2 P     P         0     0     0   1.1
3 A     P         1     0     0   2.9
4 A     P         1     0     0   3.1
5 P     B         0     1     0   3.9
6 P     B         0     1     0   4.1
7 A     B         1     1     1   9.9
8 A     B         1     1     1  10.1

Interaction model, 1

  • lm(y=a+b+a:b, data=hyp)
  • lm(y=a*b, data=hyp)
  • lm(y=i_a+i_b+i_ab, data=hyp_1)

Estimates from the hypothetical data

# A tibble: 4 × 2
  term        estimate
  <chr>          <dbl>
1 (Intercept)     1.00
2 i_a             2   
3 i_b             3   
4 i_ab            4   

Interaction model, 2

  • (Intercept): estimated average outcome with two placebos
  • i_a: estimated average change due to drug A alone
  • i_b: estimated average change due to drug B alone
  • i_ab: estimated synergistic (or antagonistic) effect of both drugs

Interaction model, 3

  • P P mean = 1
  • A P mean = 1 + 2
  • P B mean = 1 + 3
  • A B mean = 1 + 2 + 3 + 4

Line plot of hypothetical data, 2

Line plot of hypothetical data, 3

Tracking a moving target

  • gender (M or F)
  • child (Yes or No)
  • trial4 (tracking time in seconds)

Means for each combination of gender and child

# A tibble: 4 × 3
  child gender mean_trial4
  <fct> <chr>        <dbl>
1 Yes   F             2.57
2 Yes   M             2.54
3 No    F             4.46
4 No    M             6.77

Interaction plot, 1

Interaction plot, 2

Regression estimates for the interaction model

# A tibble: 4 × 5
  term            estimate std.error statistic p.value  
  <chr>              <dbl>     <dbl>     <dbl> <glue>   
1 (Intercept)       2.57       0.382    6.73   p < 0.001
2 genderM          -0.0343     0.516   -0.0666 p = 0.947
3 childNo           1.89       0.654    2.89   p = 0.005
4 genderM:childNo   2.35       0.815    2.88   p = 0.005

intercept

intercept + genderMale

intercept + childNo

intercept + genderMale + childNo

intercept + genderMale + childNo + genderMale:childNo

Live demo, Interactions in multi-factor analysis of variance

Break #2

  • What you have learned
    • Interactions in multi-factor analysis of variance
  • What’s coming next
    • Other examples of interactions

Interaction of self-esteem and outcome

Interaction of training and autonomy

Interaction of group and gender

Live demo, Other examples of interactions

Break #3

  • What you have learned
    • Other examples of interactions
  • What’s coming next
    • Interactions in analysis of covariance

Interactions in analysis of covariance

  • When you suspect an interaction
    • Graph your data
    • Draw a separate trend line for each group
    • Hope that the lines are mostly parallel
  • Compute models with and without the interaction
    • Compare using the anova function
    • Center your continuous covariate (very important!)

Example: three exercise regimens

  • Two exercise regimens, jogging, swimmin
  • One control group: reading
    • Subjects tracked hours per week (mean = 2)
  • Outcome variable, weight loss
    • Negative values represent weight gain

Visualizing the interaction

Testing the interaction

# A tibble: 2 × 7
  term                          df.residual    rss    df sumsq statistic p.value
  <chr>                               <dbl>  <dbl> <dbl> <dbl>     <dbl> <glue> 
1 loss ~ prog + hours_centered          896 43115.    NA   NA       NA   <NA>   
2 loss ~ prog + hours_centered…         894 37795.     2 5319.      62.9 p < 0.…

Coefficients and interpretation

# A tibble: 6 × 5
  term                        estimate std.error statistic p.value  
  <chr>                          <dbl>     <dbl>     <dbl> <glue>   
1 (Intercept)                    -3.70     0.376     -9.85 p < 0.001
2 progJogging                    11.8      0.531     22.3  p < 0.001
3 progSwimming                   29.6      0.531     55.7  p < 0.001
4 hours_centered                 -2.96     0.708     -4.18 p < 0.001
5 progJogging:hours_centered     10.4      1.07       9.71 p < 0.001
6 progSwimming:hours_centered     9.83     1.05       9.35 p < 0.001

Interpreting the intercept (-4)

Interpreting progJogging (12)

Interpreting progSwimming (30)

Interpreting hours_centered (-3)

Interpreting progJogging:hours_centered: (10)

Interpreting progSwimming:hours_centered: (10)

General conclusions

  • Jogging is better than reading, but only if you invest more than an hour per week.
  • Swimming is better than jogging or reading.
  • Extra time helps with the jogging and swimming interventions
  • Extra time hurts with the reading intervention

Break #4

  • What you have learned
    • Interactions in analysis of covariance
  • What’s coming next
    • Interactions in multiple linear regression

Interactions in multiple linear regression

  • Center your continuous predictors

Summary

  • What you have learned
    • Mathematical model of interactions
    • Interactions in multi-factor analysis of variance
    • Other examples of interactions
    • Interactions in analysis of covariance
    • Interactions in multiple linear regression